package edu.stanford.hardon;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import edu.stanford.hardon.Media.Media;

public class MetadataStorage implements Iterable<Media> {

	private static MetadataStorage ms;
	
	private List<Media> media;
	private UploadService notifiee;
	private boolean dirty;
	
	public static MetadataStorage getInstance() {
		if (ms == null) ms = new MetadataStorage();
		return ms;
	}
	
	public void addMedia(Media m) {
		this.media.add(m);
		this.dirty = true;
		if (this.notifiee != null) {
			//this.notifiee.tryUpload(new ArrayList<Media>(this.media));
		}
	}
	
	public boolean isDirty() {
		return this.dirty;
	}
	
	public void setNotifiee(UploadService us) {
		this.notifiee = us;
	}
	
	public Iterator<Media> iterator() {
		return media.iterator();
	}
	
	private MetadataStorage() {
		media = new ArrayList<Media>();
		dirty = false;
	}

}
